<?php
// $Id$
/**
 * This file contains {@link QueryManager} which is part of the PHP Content 
 * Repository (phpCR), a derivative of the Java Content Repository JSR-170, and 
 * is licensed under the Apache License, Version 2.0.
 *
 * This file is based on the code created for
 * {@link http://www.jcp.org/en/jsr/detail?id=170 JSR-170}
 *
 * @author Travis Swicegood <travis@domain51.net>
 * @copyright PHP Code Copyright &copy; 2004-2005, Domain51, United States
 * @copyright Original Java and Documentation 
 *  Copyright &copy; 2002-2004, Day Management AG, Switerland
 * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, 
 *      Version 2.0
 * @package phpContentRepository
 */


/**
 * Load the {@link phpCR} library file(s)
 */ 
require_once(dirname(__FILE__) . '/../phpCR.library.php');


/**
 * This interface encapsulates methods for the management of search queries.
 *
 * Provides methods for the creation and retrieval of search queries.
 *
 * @author PHP - Travis Swicegood <travis@domain51.net>
 * @copyright Copyright &copy; 2004-2005, Domain51
 * @package phpContentRepository
 */
interface QueryManager 
{
   /**
    * Creates a new query by specifying the query statement itself and the
    * language in which the query is stated.
    *
    * If the query statement is syntactically invalid, given the language 
    * specified, an {@link InvalidQueryException} is thrown.
    *
    * $language must specify a query language from among those 
    * returned by {@link QueryManager::getSupportedQueryLanguages()}; if it does
    * not then an {@link InvalidQueryException} is thrown.
    *
    * @return object
    *   A {@link Query} object.
    *
    * @throws {@link InvalidQueryException}
    *   If statement is invalid or language is unsupported.
    * @throws {@link RepositoryException}
    *   If another error occurs
    */
    public function createQuery($statement, $language);
    
    
   /**
    * Retrieves an existing persistent query.
    *
    * If $absPath is not the path of a valid persisted query an
    * {@link InvalidQueryException} is thrown.
    *
    * @see Query::save()
    * @param string
    *   The absolute path of a persisted query.
    * @return object
    *   A {@link Query} object.
    *
    * @throws {@link InvalidQueryException}
    *   If {@link absPath} is not the path of a valid persisted query or if 
    *   another error occurs.
    * @throws {@link RepositoryException}
    *   If another error occurs
    */
    public function getQuery($absPath);
    
    
   /**
    * Returns an array of integers identifying the supported query languages.
    *
    * @see QueryLanguage
    * @return array
    */
    public function getSupportedQueryLanguages();
}

